//
//  UserBSLoadCurrentUser.m
//  Teacher
//
//  Created by 马腾飞 on 15/7/30.
//  Copyright (c) 2015年 xueyinyue. All rights reserved.
//

#import "UserBSLoadCurrentUser.h"
#import "JAGPropertyConverter.h"
#import "User.h"
#import "AppConfig.h"

@implementation UserBSLoadCurrentUser

- (id)onExecute
{
    NSString *path = [AppConfig fileStrUserLocalPath];
    
    UserBSLoadCurrentUserResult *serviceResult = [[UserBSLoadCurrentUserResult alloc] init];
    
    if (![[NSFileManager defaultManager] fileExistsAtPath:path])
    {
        NSLog(@"用户文件不存在");
        return serviceResult;
    }
    
    NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
    
    JAGPropertyConverter *converter = [[JAGPropertyConverter alloc] init];
    converter.identifyDict = ^(NSDictionary *dict) {
        return [User class];
    };
    
    User *user = [converter composeModelFromObject:dict];
    
    serviceResult.data = user;
    
    return serviceResult;
}

@end

@implementation UserBSLoadCurrentUserResult


@end